package No1_100.No81_90.RemoveDuplicatesfromSortedList_83;

public class Solution {
	public static ListNode deleteDuplicates(ListNode head) {
		if (head == null) {
			return null;
		}
        int comp = head.val;
        ListNode listNode = head;
        ListNode listNode1 = listNode;
        int temp = 0;
        while (head.next != null) {
        	head = head.next;
			temp = head.val;
			if (temp == comp) {
				continue;
			}
			else {
				comp = temp;
				listNode.next = head;
				listNode = head;
			}
		}
        if (temp == comp) {
			listNode.next = null;
		}
		return listNode1;
    }
	
	public static void main(String[] args) {
		ListNode listNode = null;
//		ListNode listNode2 = new ListNode(1);
//		ListNode listNode3 = new ListNode(2);
//		listNode.next = listNode2;
//		listNode2.next = listNode3;
		ListNode result =  deleteDuplicates(listNode);
		while (result != null) {
			System.out.println(result.val);
			result = result.next;
		}
	}
}
